package com.example.stock.controller;

import com.example.stock.service.DailyDeSumService;
import com.example.stock.util.Result;
import com.example.stock.util.ResultGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("desum")
public class DailyDeSumController {

    @Autowired
    DailyDeSumService dailyDeSumService;

    @GetMapping
    public Result index() {
        return ResultGenerator.genSuccessResult(dailyDeSumService.getLatestDailyDeSum());
    }

    @GetMapping("{stock}")
    public Result stock(@PathVariable String stock) {
        return ResultGenerator.genSuccessResult(dailyDeSumService.getDailyDeSumByStock(stock));
    }
}
